<?php
$arr=[
    'id'=>1,
    ['name'=>'王五','sex'=>'女']
];

function test($arr){
    $num = count($arr[0]);
    $i=0;
    $values='';
    foreach ($arr[0] as $key => $value){
             $i++;
             if($i!=$num){
               $values.=$key.'='.'"'.$value.'",';
             }else{
                 $values.=$key.'='.'"'.$value.'"';
             }
    }
    $id=$arr['id'];
    $sql = "update test set $values where id = $id";
    echo $sql;
}

test($arr);